import xml.etree.ElementTree as ET
import os
root_path = r"C:\lwk2023\OneDrive\桌面\zhenghe_biaozhipai\leibie_modified\Annotations"

count = 0
for xml_path in os.listdir(root_path):
    path = os.path.join(root_path,xml_path)
    tree = ET.parse(path)
    root = tree.getroot()
    
    for child in root.findall("object"):
        name = child.find("name").text
        print(type(name))
        # if count == 200:
        #     break
        if name == "40140003":
            print(name)
            # root.remove(child)
            count += 1

print(count)
    # tree.write(path)






# path = r"E:\JXZX\VOC2007\test\08-53-41.635278_0.2090966839027284_1766916BE76C47C58E052D9C6738F6F3.xml"
# tree = ET.parse(path)  # 解析XML文件  
# root = tree.getroot()  # 获取根节点
# for child in root.findall("object"):
#     name = child.find("name").text
#     print(type(name))
#     if name == "40140001":
#         print(name)
#         root.remove(child)

# tree.write(path)